package cn.walls1717.ggkt.order.api;

import cn.walls1717.ggkt.model.order.OrderInfo;
import cn.walls1717.ggkt.order.service.OrderInfoService;
import cn.walls1717.ggkt.result.Result;
import cn.walls1717.ggkt.vo.order.OrderFormVo;
import cn.walls1717.ggkt.vo.order.OrderInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 前台订单相关接口
 *
 * @author walls1717
 * @since 2022/7/22
 **/
@Api(tags = "前台订单相关接口")
@RestController
@RequestMapping("api/order/orderInfo")
public class OrderInfoApiController {

    @Autowired
    private OrderInfoService orderInfoService;

    @ApiOperation("新增点播课程订单")
    @PostMapping("submitOrder")
    public Result<Long> saveSubmitOrder(@RequestBody OrderFormVo orderFormVo, HttpServletRequest request) {
        //返回订单id
        Long orderId = orderInfoService.saveSubmitOrder(orderFormVo);
        return Result.success(orderId);
    }

    @ApiOperation("根据id获取")
    @GetMapping("getInfo/{id}")
    public Result<OrderInfo> getOrderInfoById(@PathVariable Long id) {
        OrderInfoVo orderInfoVo = orderInfoService.getOrderInfoById(id);
        return Result.success(orderInfoVo);
    }
}